package su.myspringbootprojects.springsecuritylearn.controller;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Класс-контроллер ApiController
 * <p/>
 * Реализует API в нашем проекте
 * <p/>
 *
 * @author petr.mikhailin
 * created 02.07.2024 18:37
 */
@RestController
@RequestMapping("/api")
public class ApiController {
    @GetMapping("/hello")
    public ResponseEntity<String> hello() {
        return ResponseEntity.ok("Hello");
    }

    @GetMapping("/protected")
    public ResponseEntity<String> protectedResource() {
        String message = """
                This is a protected resource <br>
                You are seeing this because you are an authenticated user
                """;
        return ResponseEntity.ok(message);
    }

    @GetMapping("/admin")
    public ResponseEntity<String> admin() {
        String message = "Hello Admin";
        return ResponseEntity.ok(message);
    }
}
